package com.shanzmoo.platform.manage.api.web.product;

import com.shanzmoo.base.bean.PageRespBase;
import com.shanzmoo.base.bean.SHttpResponse;
import com.shanzmoo.db.module.product.domain.dto.UnitSaveDto;
import com.shanzmoo.db.module.product.domain.dto.UnitUpdateDto;
import com.shanzmoo.db.module.product.domain.query.UnitQueryVO;
import com.shanzmoo.db.module.product.domain.vo.UnitSelectVO;
import com.shanzmoo.db.module.product.domain.vo.UnitVO;
import com.shanzmoo.platform.manage.api.manager.product.ProductUnitManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商品单位manager
 * @author xueqz
 */
@Api(tags = "商品管理系统-单位")
@RestController
@RequestMapping("/api/product/unit")
public class ProductUnitController {

    @Autowired
    private ProductUnitManager productUnitManager;

    @ApiOperation(value = "商品单位list")
    @PostMapping("/unitList")
    public SHttpResponse<PageRespBase<UnitVO>> unitList(@RequestBody UnitQueryVO unitQueryVO) {
        return productUnitManager.getUnitListPage(unitQueryVO);
    }

    @ApiOperation(value = "添加商品单位")
    @PostMapping("/updateUnit")
    public SHttpResponse<Boolean> updateUnit(@RequestBody UnitUpdateDto unitSaveDto) {
        return productUnitManager.updateUnit(unitSaveDto);
    }

    @ApiOperation(value = "添加商品单位")
    @PostMapping("/addUnit")
    public SHttpResponse<Boolean> addUnit(@RequestBody UnitSaveDto unitSaveDto) {
        return productUnitManager.addUnit(unitSaveDto);
    }

    @ApiOperation(value = "删除商品单位")
    @GetMapping("/delUnitById")
    public SHttpResponse<Boolean> delBrandById(@RequestParam(value = "unitId") Integer unitId) {
        return productUnitManager.delBrandById(unitId);
    }

    @ApiOperation(value = "商品单位选择列表")
    @GetMapping("/selectList")
    public SHttpResponse<List<UnitSelectVO>> selectList() {
        return productUnitManager.selectList();
    }


}
